package com.wbt.bambootown.ui.activity.launcher;

import com.bigkoo.convenientbanner.ConvenientBanner;
import com.bigkoo.convenientbanner.listener.OnItemClickListener;
import com.gyf.barlibrary.ImmersionBar;
import com.wbt.bambootown.R;
import com.wbt.bambootown.cons.Cons;
import com.wbt.bambootown.ui.activity.BaseActivity;
import com.wbt.bambootown.ui.activity.LoginActivity;
import com.wbt.bambootown.utils.ActivityManagerUtil;
import com.wbt.bambootown.utils.EventCenter;
import com.wbt.bambootown.utils.SPUtils;


import java.util.ArrayList;

/**
 * Created by wufan on 2018/5/4.
 */

public class LauncherScrollActivity extends BaseActivity implements OnItemClickListener{

    private ConvenientBanner<Integer> mConvenientBanner = null;
    private static final ArrayList<Integer> INTEGERS = new ArrayList<>();


    private void initBanner(){
        INTEGERS.add(R.mipmap.launcher_01);
        INTEGERS.add(R.mipmap.launcher_02);
        INTEGERS.add(R.mipmap.launcher_03);
        INTEGERS.add(R.mipmap.launcher_04);
        INTEGERS.add(R.mipmap.launcher_05);

        mConvenientBanner
                .setPages(new LauncherHolderCreator() , INTEGERS)
                .setPageIndicator(new int[]{R.drawable.dot_normal , R.drawable.dot_focus})
                .setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.CENTER_HORIZONTAL)
                .setOnItemClickListener(this)
                .setCanLoop(false);
    }

    @Override
    public void onItemClick(int position) {
        //如果点击的是最后一个
        if(position == INTEGERS.size() - 1){
            SPUtils.putBoolean(Cons.SPCons.IS_FIRST , false);
            startActivity(LoginActivity.class);
            ActivityManagerUtil.create().finishActivity();
        }
    }

    @Override
    public void initStatusBar(ImmersionBar immersionBar) {
        immersionBar.init();
    }

    @Override
    public void initView() {
        initBanner();
    }

    @Override
    public void initData() {

    }

    @Override
    public Object getContentView() {
        mConvenientBanner = new ConvenientBanner<>(this);
        return mConvenientBanner;
    }

    @Override
    public boolean isApplyEventBus() {
        return false;
    }

    @Override
    public boolean isApplyButterKnife() {
        return false;
    }

    @Override
    public void onEventCome(EventCenter eventCenter) {

    }
}
